/**
 * 
 */
package niuke;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author zhongfang
 *
 */
public class 彩色的砖块 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		String string=scanner.nextLine();
		ArrayList<Character> characters=new ArrayList<>(2);
		int res=-1;
		for (int i = 0; i < string.length(); i++) {
			if(characters.contains(string.charAt(i))){
				continue;
			}
			if(characters.size()==2){
				res=0;
				break;
			}
			characters.add(string.charAt(i));
		}
		if(res==-1){
			res=characters.size();
		}
		System.out.println(res);
	}

}
